/**
 * @param {string[]} arr
 * @param {number} k
 * @return {string}
 */
 var kthDistinct = function(arr, k) {
  let s = new Set(), r = new Set()
  for(let x of arr){
    if(s.has(x)){
      r.add(x)
    }
    s.add(x)
  }
  arr = arr.filter(v => !r.has(v))
  return arr.length >= k ? arr[k-1] : ''
};